#include<bits/stdc++.h>
using namespace std;
int main()
{
int sum;
int n,x=0;
cin>>n>>x;
stringstream ss;
for(n++;--n;ss<<n);

string c=ss.str();
sum=count(c.begin(),c.end(),x+'0');
cout<<sum;

}
